import { PSControlObjectImpl } from '../pscontrol-object-impl';
import { IPSChartDataSetField } from './ipschart-data-set-field';
import { IPSDEChartDataSet } from './ipsdechart-data-set';

export class PSDEChartDataSetImpl extends PSControlObjectImpl implements IPSDEChartDataSet {
  get index(): number {
    return this.M.index;
  }

  protected pschartdatasetfields: IPSChartDataSetField[] | null = null;

  getPSChartDataSetFields(): IPSChartDataSetField[] | null {
    if (this.pschartdatasetfields == null) {
      this.pschartdatasetfields = this.fillChildListModel(this.M.getPSChartDataSetFields, 'control.chart.IPSChartDataSetField') as IPSChartDataSetField[];
    }
    return this.pschartdatasetfields;
  }

  get psChartDataSetFields(): IPSChartDataSetField[] | null {
    return this.getPSChartDataSetFields();
  }

  findPSChartDataSetField(objKey: any): IPSChartDataSetField | null {
    return this.getPSModel5('control.chart.IPSChartDataSetField', this.getPSChartDataSetFields(), objKey) as IPSChartDataSetField;
  }

  get cls(): string {
    return 'PSDEChartDataSetImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.chart.IPSChartDataSet' || cls == 'control.chart.IPSDEChartDataSet') return true;
    return super.instanceof(cls);
  }
}
